package com.springdemo.annother.parseexcel.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpClientUtil {
	public static String doGet(String url){
		StringBuffer buffer = null;
		try{
			URL u = new URL(url);
			HttpURLConnection coon = (HttpURLConnection) u.openConnection();
			coon.setRequestMethod("GET");
			coon.setDoOutput(true);
			coon.setDoInput(true);
			coon.connect();
			//读取服务器端返回的内容
			InputStream is = coon.getInputStream();
			InputStreamReader isr = new InputStreamReader(is ,"utf-8");
			BufferedReader br = new BufferedReader(isr);
			buffer = new StringBuffer(); 
			String line = null;
			while((line = br.readLine()) !=null){
				buffer.append(line);
			}
			br.close();
		} catch(Exception e){
			e.printStackTrace();
		}
		
		return buffer.toString(); 
	}
}
